﻿<UserControl x:Class="Xinnos.Lca.Yacht.Analyzer.View.ObjectRatioPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.CommandBindings>
        <CommandBinding Command="New" CanExecute="OnCanExecuteNewCommand" Executed="OnExecuteNewCommand" />
        <CommandBinding Command="Delete" CanExecute="OnCanExecuteRemoveCommand" Executed="OnExecuteRemoveCommand" />
    </UserControl.CommandBindings>
    <UserControl.Resources>
        <Style TargetType="{x:Type DataGridColumnHeader}">
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="2" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <DataGrid Grid.Column="0" ItemsSource="{Binding Ratios}" SelectedItem="{Binding Ratio}" AutoGenerateColumns="False" CanUserAddRows="False" >
            <DataGrid.ContextMenu>
                <ContextMenu>
                    <MenuItem Command="New" CommandTarget="{Binding Path=PlacementTarget,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ContextMenu}}}" />
                    <MenuItem Command="Delete" CommandTarget="{Binding Path=PlacementTarget,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ContextMenu}}}" />
                </ContextMenu>
            </DataGrid.ContextMenu>
            <DataGrid.Columns>
                <DataGridComboBoxColumn Header="부재" Width="*" x:Name="componentsColumn" SelectedItemBinding="{Binding Component,Mode=TwoWay}" DisplayMemberPath="Name" />
                <DataGridTextColumn Header="면적" Width="*" Binding="{Binding Area,StringFormat=N2}">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="HorizontalAlignment" Value="Center" />
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>
        <GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="DarkGray" ResizeBehavior="PreviousAndNext" ResizeDirection="Columns" />
        <Grid Grid.Column="2">
            <chartingToolkit:Chart x:Name="chartPie" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Title="Components Ratio">
                <chartingToolkit:PieSeries HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Ratios}" DependentValuePath="Area" IndependentValuePath="Component.Name" />
            </chartingToolkit:Chart>
        </Grid>
    </Grid>
</UserControl>